<?php
/**
 * User: @lixu
 * Date: 2019-03-05
 * Time: 16:23
 */

namespace Biz\model;

use Doraemon\pockets\datebase\BaseDbModel;

class ShopBannerGrabConfig  extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_shop';

    const _CONFIG_SELECT_ = 'db_shop';

    const _DATABASE_ = 'shop';

    const _TABLE_NAME = 'shop_banner_grab_config';

    // 状态为正常
    const STATUS_NORMAL = 1;
    // 状态为被删除
    const STATUS_DELETE = 9;

    const TYPE_CATEGORY = 1;
    const TYPE_KEYWORD = 2;
    const TYPE_TAGS = 3;

    public static function getInfo($where, $field = '*')
    {
        return self::get($field, $where);
    }

    public static function add($data)
    {
        $data['addtime'] = date("Y-m-d H:i:s");
        if (self::insert($data)->rowcount()) {
            return self::id();
        }
        return false;
    }

    public static function updateByBannerId($bannerId, $data)
    {
        if (self::update($data, ['banner_id' => $bannerId])->rowcount()) {
            return $bannerId;
        }
        return false;
    }

    public static function getList($where, $field = '*')
    {
        return self::select($field, $where);
    }
}